package com.cbl.v.ssczs.mode.util;

import android.content.Context;

import com.bigkoo.svprogresshud.SVProgressHUD;

/**
 * Created by dell on 2017/5/27.
 */

public class DialogUtils {

    private static SVProgressHUD mDialog;

    /**
     * 初始化dailog
     *
     * @param context
     */
    public static void initDialog(Context context) {
        if (mDialog == null){
            mDialog = new SVProgressHUD(context);
        }else {
            mDialog.dismiss();
        }
    }

    public void show() {
        mDialog.show();
    }

    /**
     * 显示请求网络对话框
     *
     * @param msg
     */
    public static void showWithStatus(String msg,Context context) {
        initDialog(context);
        mDialog.showWithStatus(msg);
    }

    public static void showWithStatus(Context context) {
        initDialog(context);
        mDialog.showWithStatus("请稍等");
    }

    public static void showInfoWithStatus(String msg,Context context) {
        initDialog(context);
        mDialog.showInfoWithStatus(msg, SVProgressHUD.SVProgressHUDMaskType.BlackCancel);
    }

    public static void showSuccessWithStatus(String msg,Context context) {
        initDialog(context);
        mDialog.showSuccessWithStatus(msg);
    }

    public static void showErrorWithStatus(String msg,Context context) {
        initDialog(context);
        mDialog.showErrorWithStatus(msg, SVProgressHUD.SVProgressHUDMaskType.BlackCancel);
    }

    public static void disMissDialog() {
        if (mDialog != null){
            mDialog.dismiss();
            mDialog=null;
        }
    }

    public static SVProgressHUD getDialog(Context context){
        if (mDialog==null){
            mDialog=new SVProgressHUD(context);
            return mDialog;
        }else {
            return mDialog;
        }
    }


}
